import dayjs from "dayjs";

export enum Format {
  YYYY_MM_DD_HH_MM_SS_SSS = 'YYYY-MM-DD HH:mm:ss.SSS',
  YYYY_MM_DD_HH_MM_SS = 'YYYY-MM-DD HH:mm:ss'
}

export function format(date: Date | null, format: Format) {
  const day = dayjs(date)
  if (day.isValid()) {
    return day.format(format)
  } else {
    return ''
  }
}
